package clasesweb;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.*;
import javax.servlet.http.*;

public class MyAction extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void doGet(HttpServletRequest request, 
                      HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head><title>MyAction</title></head>");
        out.println("<body>");
        out.println("<h1>Se ha ejecutato el metodo GET</h1>");
        
        out.println("Apellido Paterno: " + request.getParameter("ApelPaterno") + "<br/>");
        out.println("Apellido Materno: " + request.getParameter("ApelMaterno") + "<br/>");
        out.println("Nombres " + request.getParameter("Nombres"));
        out.println("Direccion: " + request.getParameter("Direccion"));
                               
        out.println("</body></html>");
        out.close();
    }

    public void doPost(HttpServletRequest request, 
                       HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head><title>MyAction</title></head>");
        out.println("<body>");
        out.println("<h1>he servlet has received a POST.</h1>");
        
        out.println("Apellido Paterno: " + request.getParameter("ApelPaterno") + "<br/>");
        out.println("Apellido Materno: " + request.getParameter("ApelMaterno") + "<br/>");
        out.println("Nombres " + request.getParameter("Nombres"));
        out.println("Direccion: " + request.getParameter("Direccion"));
        
        out.println("</body></html>");
        out.close();
    }
}
